# -*-coding:utf8

from datetime import datetime
from selenium import webdriver
from public.pages.BasePage import BasePage
from Data.ElementData.baiduElement import baidu_Elemert_Date
from time import sleep
from Data.TestData.TestData import Data
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from faker import Faker
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

class BaiduPage(BasePage, baidu_Elemert_Date, Data):
    def gotobaidu(self,url=Data.get_data()[0]):
        self.driver.get(url)

    def baidusearch(self,data=Data.get_data()[1]):
        self.send(self.search_input, data)
        self.click(self.search_btn)

    # 定义driver
    @classmethod
    def setdriver_cls(cls):
        print('开始测试')
        desired_capabilities = DesiredCapabilities.CHROME
        desired_capabilities["pageLoadStrategy"] = "none"  # 设置页面加载等待为none，不需要等待页面所有元素加载完即可开始操作
        chrome_options = Options()
        # chrome_options.add_argument('--headless')               # 设置无界面模式运行
        chrome_options.add_argument('--window-size=1920,962')  # 设置无界面模式下浏览器分辨率
        cls.driver = webdriver.Chrome(desired_capabilities=desired_capabilities, options=chrome_options)
        cls.driver.maximize_window()
        sleep(2)



    def setdriver(self):
        print('开始测试')
        desired_capabilities = DesiredCapabilities.CHROME
        desired_capabilities["pageLoadStrategy"] = "none"       # 设置页面加载等待为none，不需要等待页面所有元素加载完即可开始操作
        chrome_options = Options()
        # chrome_options.add_argument('--headless')               # 设置无界面模式运行
        # chrome_options.add_argument('--window-size=1920,962')   # 设置无界面模式下浏览器分辨率
        self.driver = webdriver.Chrome(desired_capabilities=desired_capabilities, options=chrome_options)
        self.driver.maximize_window()
        sleep(2)